#include "CommonHeaders.h"

Jogo::Jogo()
{
	j=0;
	done=false;
}

Jogo::~Jogo()
{
	
}

bool Jogo::verificaVetor(int indice, int vet[54])
{
	int i;
    for(i=0;i<=53;i++)
    {
        if(vet[i]==indice)
            return true;
    }
    return false;
}

void Jogo::iniciaGame()
{
	for(i=0;i<=53;i++)
    {
        indicesUsados[i]=-1;
    }

    srand(time(NULL));

	num=1;
	naipe=1;
	for(i=0;i<=51;i++)
    {
        baralho[i].setNum(num);
        baralho[i].setNaipe(naipe);
        num++;
        if(num==14)
        {
            num=1;
            naipe++;
        }
    }
    baralho[52].setNum(0);
    baralho[52].setNaipe(1);
    baralho[53].setNum(0);
    baralho[53].setNaipe(2);

    for(i=0;i<=6;i++)
    {
        do
        {
            indice=rand()%54;
        }while(verificaVetor(indice,indicesUsados));
        indicesUsados[j]=indice;
        j++;
        num=baralho[indice].getNum();
        naipe=baralho[indice].getNaipe();

		aux.setNum(num);
		aux.setNaipe(naipe);
        coluna1.Empilha(aux);

    }
    for(i=0;i<=6;i++)
    {
        do
        {
            indice=rand()%54;
        }while(verificaVetor(indice,indicesUsados));
        indicesUsados[j]=indice;
        j++;
        num=baralho[indice].getNum();
        naipe=baralho[indice].getNaipe();
        
		aux.setNum(num);
		aux.setNaipe(naipe);
        coluna2.Empilha(aux);

    }
    for(i=0;i<=6;i++)
    {
        do
        {
            indice=rand()%54;
        }while(verificaVetor(indice,indicesUsados));
        indicesUsados[j]=indice;
        j++;
        num=baralho[indice].getNum();
        naipe=baralho[indice].getNaipe();

        aux.setNum(num);
		aux.setNaipe(naipe);
        coluna3.Empilha(aux);

    }
    for(i=0;i<=6;i++)
    {
        do
        {
            indice=rand()%54;
        }while(verificaVetor(indice,indicesUsados));
        indicesUsados[j]=indice;
        j++;
        num=baralho[indice].getNum();
        naipe=baralho[indice].getNaipe();

        aux.setNum(num);
		aux.setNaipe(naipe);
        coluna4.Empilha(aux);

    }
    for(i=0;i<=6;i++)
    {
        do
        {
            indice=rand()%54;
        }while(verificaVetor(indice,indicesUsados));
        indicesUsados[j]=indice;
        j++;
        num=baralho[indice].getNum();
        naipe=baralho[indice].getNaipe();

		aux.setNum(num);
		aux.setNaipe(naipe);
        coluna5.Empilha(aux);

    }
    for(i=0;i<=6;i++)
    {
        do
        {
            indice=rand()%54;
        }while(verificaVetor(indice,indicesUsados));
        indicesUsados[j]=indice;
        j++;
        num=baralho[indice].getNum();
        naipe=baralho[indice].getNaipe();
        
		aux.setNum(num);
		aux.setNaipe(naipe);
        coluna6.Empilha(aux);

    }
    for(i=0;i<=5;i++)
    {
        do
        {
            indice=rand()%54;
        }while(verificaVetor(indice,indicesUsados));
        indicesUsados[j]=indice;
        j++;
        num=baralho[indice].getNum();
        naipe=baralho[indice].getNaipe();
        
		aux.setNum(num);
		aux.setNaipe(naipe);
        coluna7.Empilha(aux);

    }
    for(i=0;i<=5;i++)
    {
        do
        {
            indice=rand()%54;
        }while(verificaVetor(indice,indicesUsados));
        indicesUsados[j]=indice;
        j++;
        num=baralho[indice].getNum();
        naipe=baralho[indice].getNaipe();
        
		aux.setNum(num);
		aux.setNaipe(naipe);
        coluna8.Empilha(aux);
	}

	j=0;
}

void Jogo::destroiGame()
{
	reserva1.setVazia();
	reserva2.setVazia();
	reserva3.setVazia();
	reserva4.setVazia();

	cima1.setVazia();
	cima2.setVazia();
	cima3.setVazia();
	cima4.setVazia();

	coluna1.setVazia();
	coluna2.setVazia();
	coluna3.setVazia();
	coluna4.setVazia();
	coluna5.setVazia();
	coluna6.setVazia();
	coluna7.setVazia();
	coluna8.setVazia();
}

void Jogo::iniciaGrafico()
{
	
	al_init();
    al_init_image_addon();
	al_install_mouse();

    janela = al_create_display(860,640 );
	al_set_window_title(janela,"BlackCell");
	icon=al_load_bitmap("icon.png");
	al_set_display_icon(janela,icon);
    fundo = al_load_bitmap("fundo.png");
	win = al_load_bitmap("WinBar.png");
	fila = al_create_event_queue();     
	
	
	al_register_event_source(fila, al_get_mouse_event_source());
	al_register_event_source(fila, al_get_display_event_source(janela));
	
}

void Jogo::printGame()
{
	int FPS=60;
	
	int i=0,mouseX,mouseY,origem=-1,destino=-1;
	bool desenhar=true;

	timer = al_create_timer(1.0/FPS);
	al_register_event_source(fila,al_get_timer_event_source(timer));

	iniciaGame();

	al_draw_bitmap(fundo, 0, 0, 0);
	
	al_start_timer(timer);
	while(!done)
	{	
		if(cima1.ganhou() && cima2.ganhou() && cima3.ganhou() && cima4.ganhou())
			al_draw_bitmap(win,0,245,0);
		
		al_flip_display();
		
		al_wait_for_event(fila,&ev);
		
		//sair
		if(ev.type == ALLEGRO_EVENT_MOUSE_BUTTON_DOWN)
			if(ev.mouse.x>=805 && ev.mouse.x<=835 && ev.mouse.y>=590 && ev.mouse.y<=620)
				done=true;
		//restart
		if(ev.type == ALLEGRO_EVENT_MOUSE_BUTTON_DOWN)
			if(ev.mouse.x>=765 && ev.mouse.x<=795 && ev.mouse.y>=590 && ev.mouse.y<=620)
			{
				destroiGame();
				iniciaGame();

				al_draw_bitmap(fundo,0,0,0);

				reserva1.print(inix*1,10,&lastX[0],&lastY[0]);
				reserva2.print(inix*2,10,&lastX[1],&lastY[1]);
				reserva3.print(inix*3,10,&lastX[2],&lastY[2]);
				reserva4.print(inix*4,10,&lastX[3],&lastY[3]);

				cima1.print(inix*5+40,10,&lastX[4],&lastY[4]);
				cima2.print(inix*6+40,10,&lastX[5],&lastY[5]);
				cima3.print(inix*7+40,10,&lastX[6],&lastY[6]);
				cima4.print(inix*8+40,10,&lastX[7],&lastY[7]);

				coluna1.Print(inix*1+20,iniy,&lastX[8],&lastY[8]);
				coluna2.Print(inix*2+20,iniy,&lastX[9],&lastY[9]);
				coluna3.Print(inix*3+20,iniy,&lastX[10],&lastY[10]);
				coluna4.Print(inix*4+20,iniy,&lastX[11],&lastY[11]);
				coluna5.Print(inix*5+20,iniy,&lastX[12],&lastY[12]);
				coluna6.Print(inix*6+20,iniy,&lastX[13],&lastY[13]);
				coluna7.Print(inix*7+20,iniy,&lastX[14],&lastY[14]);
				coluna8.Print(inix*8+20,iniy,&lastX[15],&lastY[15]);
			}
		if(ev.type== ALLEGRO_EVENT_MOUSE_BUTTON_DOWN)
		{
			origem=verificaClique(ev.mouse.x,ev.mouse.y);
		}
		else if(ev.type== ALLEGRO_EVENT_MOUSE_BUTTON_UP)
		{
			destino=verificaClique(ev.mouse.x,ev.mouse.y);
		}else if(ev.type==ALLEGRO_EVENT_DISPLAY_CLOSE)
			done=true;
		else if (ev.type == ALLEGRO_EVENT_TIMER)
		{
			if(transfere(origem,destino))
			{
				al_draw_bitmap(fundo,0,0,0);
				origem = -1;
				destino = -1;
				desenhar = true;
			}
		}
		

		
		
		if(desenhar && al_is_event_queue_empty(fila))
		{
		
			reserva1.print(inix*1,10,&lastX[0],&lastY[0]);
			reserva2.print(inix*2,10,&lastX[1],&lastY[1]);
			reserva3.print(inix*3,10,&lastX[2],&lastY[2]);
			reserva4.print(inix*4,10,&lastX[3],&lastY[3]);

			cima1.print(inix*5+40,10,&lastX[4],&lastY[4]);
			cima2.print(inix*6+40,10,&lastX[5],&lastY[5]);
			cima3.print(inix*7+40,10,&lastX[6],&lastY[6]);
			cima4.print(inix*8+40,10,&lastX[7],&lastY[7]);

			coluna1.Print(inix*1+20,iniy,&lastX[8],&lastY[8]);
			coluna2.Print(inix*2+20,iniy,&lastX[9],&lastY[9]);
			coluna3.Print(inix*3+20,iniy,&lastX[10],&lastY[10]);
			coluna4.Print(inix*4+20,iniy,&lastX[11],&lastY[11]);
			coluna5.Print(inix*5+20,iniy,&lastX[12],&lastY[12]);
			coluna6.Print(inix*6+20,iniy,&lastX[13],&lastY[13]);
			coluna7.Print(inix*7+20,iniy,&lastX[14],&lastY[14]);
			coluna8.Print(inix*8+20,iniy,&lastX[15],&lastY[15]);

			desenhar = false;
		}


	}

		al_destroy_display(janela);
		al_destroy_bitmap(fundo);
		al_destroy_bitmap(cartas);
		al_destroy_event_queue(fila);
}

int Jogo::verificaClique(int mouseX, int mouseY)
{
	int origem=0;

	if(mouseX>=lastX[0] && mouseX<=lastX[0]+72 && mouseY>=lastY[0] && mouseY<=lastY[0]+96) 
		origem=1;
	if(mouseX>=lastX[1] && mouseX<=lastX[1]+72 && mouseY>=lastY[1] && mouseY<=lastY[1]+96) 
		origem=2;
	if(mouseX>=lastX[2] && mouseX<=lastX[2]+72 && mouseY>=lastY[2] && mouseY<=lastY[2]+96)
		origem=3;
	if(mouseX>=lastX[3] && mouseX<=lastX[3]+72 && mouseY>=lastY[3] && mouseY<=lastY[3]+96) 
		origem=4;
	if(mouseX>=lastX[4] && mouseX<=lastX[4]+72 && mouseY>=lastY[4] && mouseY<=lastY[4]+96) 
		origem=5;
	if(mouseX>=lastX[5] && mouseX<=lastX[5]+72 && mouseY>=lastY[5] && mouseY<=lastY[5]+96) 
		origem=6;
	if(mouseX>=lastX[6] && mouseX<=lastX[6]+72 && mouseY>=lastY[6] && mouseY<=lastY[6]+96) 
		origem=7;
	if(mouseX>=lastX[7] && mouseX<=lastX[7]+72 && mouseY>=lastY[7] && mouseY<=lastY[7]+96)
		origem=8;
	if(mouseX>=lastX[8] && mouseX<=lastX[8]+72 && mouseY>=lastY[8] && mouseY<=lastY[8]+96)
		origem=9;
	if(mouseX>=lastX[9] && mouseX<=lastX[9]+72 && mouseY>=lastY[9] && mouseY<=lastY[9]+96) 
		origem=10;
	if(mouseX>=lastX[10] && mouseX<=lastX[10]+72 && mouseY>=lastY[10] && mouseY<=lastY[10]+96) 
		origem=11;
	if(mouseX>=lastX[11] && mouseX<=lastX[11]+72 && mouseY>=lastY[11] && mouseY<=lastY[11]+96)
		origem=12;
	if(mouseX>=lastX[12] && mouseX<=lastX[12]+72 && mouseY>=lastY[12] && mouseY<=lastY[12]+96) 
		origem=13;
	if(mouseX>=lastX[13] && mouseX<=lastX[13]+72 && mouseY>=lastY[13] && mouseY<=lastY[13]+96) 
		origem=14;
	if(mouseX>=lastX[14] && mouseX<=lastX[14]+72 && mouseY>=lastY[14] && mouseY<=lastY[14]+96) 
		origem=15;
	if(mouseX>=lastX[15] && mouseX<=lastX[15]+72 && mouseY>=lastY[15] && mouseY<=lastY[15]+96)
		origem=16;
	
	return origem; 
}

bool Jogo::transfere(int origem,int destino)
{
	if( origem == -1 || destino == -1)
		return false;

	switch(origem)
	{
		case 1:
			switch(destino)
			{
				case 2:
					reserva1.trocaCarta(&reserva2);
					return true;
				break;
				case 3:
					reserva1.trocaCarta(&reserva3);
					return true;
				break;
				case 4:
					reserva1.trocaCarta(&reserva4);
					return true;
				break;
				case 5:
					reserva1.sobeCarta(&cima1);
					return true;
				break;
				case 6:
					reserva1.sobeCarta(&cima2);
					return true;
				break;
				case 7:
					reserva1.sobeCarta(&cima3);
					return true;
				break;
				case 8:
					reserva1.sobeCarta(&cima4);
					return true;
				break;
				case 9:
					coluna1.TiraReserva(&reserva1);
					return true;
				break;
				case 10:
					coluna2.TiraReserva(&reserva1);
					return true;
				break;
				case 11:
					coluna3.TiraReserva(&reserva1);
					return true;
				break;
				case 12:
					coluna4.TiraReserva(&reserva1);
					return true;
				break;
				case 13:
					coluna5.TiraReserva(&reserva1);
					return true;
				break;
				case 14:
					coluna6.TiraReserva(&reserva1);
					return true;
				break;
				case 15:
					coluna7.TiraReserva(&reserva1);
					return true;
				break;
				case 16:
					coluna8.TiraReserva(&reserva1);
					return true;
				break;
			}
		break;
		case 2:
			switch(destino)
			{
				case 1:
					reserva2.trocaCarta(&reserva1);
					return true;
				break;
				case 3:
					reserva2.trocaCarta(&reserva3);
					return true;
				break;
				case 4:
					reserva2.trocaCarta(&reserva4);
					return true;
				break;
				case 5:
					reserva2.sobeCarta(&cima1);
					return true;
				break;
				case 6:
					reserva2.sobeCarta(&cima2);
					return true;
				break;
				case 7:
					reserva2.sobeCarta(&cima3);
					return true;
				break;
				case 8:
					reserva2.sobeCarta(&cima4);
					return true;
				break;
				case 9:
					coluna1.TiraReserva(&reserva2);
					return true;
				break;
				case 10:
					coluna2.TiraReserva(&reserva2);
					return true;
				break;
				case 11:
					coluna3.TiraReserva(&reserva2);
					return true;
				break;
				case 12:
					coluna4.TiraReserva(&reserva2);
					return true;
				break;
				case 13:
					coluna5.TiraReserva(&reserva2);
					return true;
				break;
				case 14:
					coluna6.TiraReserva(&reserva2);
					return true;
				break;
				case 15:
					coluna7.TiraReserva(&reserva2);
					return true;
				break;
				case 16:
					coluna8.TiraReserva(&reserva2);
					return true;
				break;
			}
		break;
		case 3:
			switch(destino)
			{
				case 1:
					reserva3.trocaCarta(&reserva1);
					return true;
				break;
				case 2:
					reserva3.trocaCarta(&reserva2);
					return true;
				break;
				case 4:
					reserva3.trocaCarta(&reserva4);
					return true;
				break;
				case 5:
					reserva3.sobeCarta(&cima1);
					return true;
				break;
				case 6:
					reserva3.sobeCarta(&cima2);
					return true;
				break;
				case 7:
					reserva3.sobeCarta(&cima3);
					return true;
				break;
				case 8:
					reserva3.sobeCarta(&cima4);
					return true;
				break;
				case 9:
					coluna1.TiraReserva(&reserva3);
					return true;
				break;
				case 10:
					coluna2.TiraReserva(&reserva3);
					return true;
				break;
				case 11:
					coluna3.TiraReserva(&reserva3);
					return true;
				break;
				case 12:
					coluna4.TiraReserva(&reserva3);
					return true;
				break;
				case 13:
					coluna5.TiraReserva(&reserva3);
					return true;
				break;
				case 14:
					coluna6.TiraReserva(&reserva3);
					return true;
				break;
				case 15:
					coluna7.TiraReserva(&reserva3);
					return true;
				break;
				case 16:
					coluna8.TiraReserva(&reserva3);
					return true;
				break;
			}
		break;
		case 4:
			switch(destino)
			{
				case 1:
					reserva4.trocaCarta(&reserva1);
					return true;
				break;
				case 2:
					reserva4.trocaCarta(&reserva2);
					return true;
				break;
				case 3:
					reserva4.trocaCarta(&reserva3);
					return true;
				break;
				case 5:
					reserva4.sobeCarta(&cima1);
					return true;
				break;
				case 6:
					reserva4.sobeCarta(&cima2);
					return true;
				break;
				case 7:
					reserva4.sobeCarta(&cima3);
					return true;
				break;
				case 8:
					reserva4.sobeCarta(&cima4);
					return true;
				break;
				case 9:
					coluna1.TiraReserva(&reserva4);
					return true;
				break;
				case 10:
					coluna2.TiraReserva(&reserva4);
					return true;
				break;
				case 11:
					coluna3.TiraReserva(&reserva4);
					return true;
				break;
				case 12:
					coluna4.TiraReserva(&reserva4);
					return true;
				break;
				case 13:
					coluna5.TiraReserva(&reserva4);
					return true;
				break;
				case 14:
					coluna6.TiraReserva(&reserva4);
					return true;
				break;
				case 15:
					coluna7.TiraReserva(&reserva4);
					return true;
				break;
				case 16:
					coluna8.TiraReserva(&reserva4);
					return true;
				break;
			}
		break;
		case 9:
			switch(destino)
			{
				case 1:
					coluna1.ParaReserva(&reserva1);
					return true;
				break;
				case 2:
					coluna1.ParaReserva(&reserva2);
					return true;
				break;
				case 3:
					coluna1.ParaReserva(&reserva3);
					return true;
				break;
				case 4:
					coluna1.ParaReserva(&reserva4);
					return true;
				break;
				case 5:
					coluna1.SobeCarta(&cima1);
					return true;
				break;
				case 6:
					coluna1.SobeCarta(&cima2);
					return true;
				break;
				case 7:
					coluna1.SobeCarta(&cima3);
					return true;
				break;
				case 8:
					coluna1.SobeCarta(&cima4);
					return true;
				break;
				case 10:
					coluna1.TransfereCarta(&coluna2);
					return true;
				break;
				case 11:
					coluna1.TransfereCarta(&coluna3);
					return true;
				break;
				case 12:
					coluna1.TransfereCarta(&coluna4);
					return true;
				break;
				case 13:
					coluna1.TransfereCarta(&coluna5);
					return true;
				break;
				case 14:
					coluna1.TransfereCarta(&coluna6);
					return true;
				break;
				case 15:
					coluna1.TransfereCarta(&coluna7);
					return true;
				break;
				case 16:
					coluna1.TransfereCarta(&coluna8);
					return true;
				break;
			}
		break;
		case 10:
			switch(destino)
			{
				case 1:
					coluna2.ParaReserva(&reserva1);
					return true;
				break;
				case 2:
					coluna2.ParaReserva(&reserva2);
					return true;
				break;
				case 3:
					coluna2.ParaReserva(&reserva3);
					return true;
				break;
				case 4:
					coluna2.ParaReserva(&reserva4);
					return true;
				break;
				case 5:
					coluna2.SobeCarta(&cima1);
					return true;
				break;
				case 6:
					coluna2.SobeCarta(&cima2);
					return true;
				break;
				case 7:
					coluna2.SobeCarta(&cima3);
					return true;
				break;
				case 8:
					coluna2.SobeCarta(&cima4);
					return true;
				break;
				case 9:
					coluna2.TransfereCarta(&coluna1);
					return true;
				break;
				case 11:
					coluna2.TransfereCarta(&coluna3);
					return true;
				break;
				case 12:
					coluna2.TransfereCarta(&coluna4);
					return true;
				break;
				case 13:
					coluna2.TransfereCarta(&coluna5);
					return true;
				break;
				case 14:
					coluna2.TransfereCarta(&coluna6);
					return true;
				break;
				case 15:
					coluna2.TransfereCarta(&coluna7);
					return true;
				break;
				case 16:
					coluna2.TransfereCarta(&coluna8);
					return true;
				break;
			}
		break;
		case 11:
			switch(destino)
			{
				case 1:
					coluna3.ParaReserva(&reserva1);
					return true;
				break;
				case 2:
					coluna3.ParaReserva(&reserva2);
					return true;
				break;
				case 3:
					coluna3.ParaReserva(&reserva3);
					return true;
				break;
				case 4:
					coluna3.ParaReserva(&reserva4);
					return true;
				break;
				case 5:
					coluna3.SobeCarta(&cima1);
					return true;
				break;
				case 6:
					coluna3.SobeCarta(&cima2);
					return true;
				break;
				case 7:
					coluna3.SobeCarta(&cima3);
					return true;
				break;
				case 8:
					coluna3.SobeCarta(&cima4);
					return true;
				break;
				case 10:
					coluna3.TransfereCarta(&coluna2);
					return true;
				break;
				case 9:
					coluna3.TransfereCarta(&coluna1);
					return true;
				break;
				case 12:
					coluna3.TransfereCarta(&coluna4);
					return true;
				break;
				case 13:
					coluna3.TransfereCarta(&coluna5);
					return true;
				break;
				case 14:
					coluna3.TransfereCarta(&coluna6);
					return true;
				break;
				case 15:
					coluna3.TransfereCarta(&coluna7);
					return true;
				break;
				case 16:
					coluna3.TransfereCarta(&coluna8);
					return true;
				break;
			}
		break;
		case 12:
			switch(destino)
			{
				case 1:
					coluna4.ParaReserva(&reserva1);
					return true;
				break;
				case 2:
					coluna4.ParaReserva(&reserva2);
					return true;
				break;
				case 3:
					coluna4.ParaReserva(&reserva3);
					return true;
				break;
				case 4:
					coluna4.ParaReserva(&reserva4);
					return true;
				break;
				case 5:
					coluna4.SobeCarta(&cima1);
					return true;
				break;
				case 6:
					coluna4.SobeCarta(&cima2);
					return true;
				break;
				case 7:
					coluna4.SobeCarta(&cima3);
					return true;
				break;
				case 8:
					coluna4.SobeCarta(&cima4);
					return true;
				break;
				case 10:
					coluna4.TransfereCarta(&coluna2);
					return true;
				break;
				case 11:
					coluna4.TransfereCarta(&coluna3);
					return true;
				break;
				case 9:
					coluna4.TransfereCarta(&coluna1);
					return true;
				break;
				case 13:
					coluna4.TransfereCarta(&coluna5);
					return true;
				break;
				case 14:
					coluna4.TransfereCarta(&coluna6);
					return true;
				break;
				case 15:
					coluna4.TransfereCarta(&coluna7);
					return true;
				break;
				case 16:
					coluna4.TransfereCarta(&coluna8);
					return true;
				break;
			}
		break;
		case 13:
			switch(destino)
			{
				case 1:
					coluna5.ParaReserva(&reserva1);
					return true;
				break;
				case 2:
					coluna5.ParaReserva(&reserva2);
					return true;
				break;
				case 3:
					coluna5.ParaReserva(&reserva3);
					return true;
				break;
				case 4:
					coluna5.ParaReserva(&reserva4);
					return true;
				break;
				case 5:
					coluna5.SobeCarta(&cima1);
					return true;
				break;
				case 6:
					coluna5.SobeCarta(&cima2);
					return true;
				break;
				case 7:
					coluna5.SobeCarta(&cima3);
					return true;
				break;
				case 8:
					coluna5.SobeCarta(&cima4);
					return true;
				break;
				case 10:
					coluna5.TransfereCarta(&coluna2);
					return true;
				break;
				case 11:
					coluna5.TransfereCarta(&coluna3);
					return true;
				break;
				case 12:
					coluna5.TransfereCarta(&coluna4);
					return true;
				break;
				case 9:
					coluna5.TransfereCarta(&coluna1);
					return true;
				break;
				case 14:
					coluna5.TransfereCarta(&coluna6);
					return true;
				break;
				case 15:
					coluna5.TransfereCarta(&coluna7);
					return true;
				break;
				case 16:
					coluna5.TransfereCarta(&coluna8);
					return true;
				break;
			}
		break;
		case 14:
			switch(destino)
			{
				case 1:
					coluna6.ParaReserva(&reserva1);
					return true;
				break;
				case 2:
					coluna6.ParaReserva(&reserva2);
					return true;
				break;
				case 3:
					coluna6.ParaReserva(&reserva3);
					return true;
				break;
				case 4:
					coluna6.ParaReserva(&reserva4);
					return true;
				break;
				case 5:
					coluna6.SobeCarta(&cima1);
					return true;
				break;
				case 6:
					coluna6.SobeCarta(&cima2);
					return true;
				break;
				case 7:
					coluna6.SobeCarta(&cima3);
					return true;
				break;
				case 8:
					coluna6.SobeCarta(&cima4);
					return true;
				break;
				case 10:
					coluna6.TransfereCarta(&coluna2);
					return true;
				break;
				case 11:
					coluna6.TransfereCarta(&coluna3);
					return true;
				break;
				case 12:
					coluna6.TransfereCarta(&coluna4);
					return true;
				break;
				case 13:
					coluna6.TransfereCarta(&coluna5);
					return true;
				break;
				case 9:
					coluna6.TransfereCarta(&coluna1);
					return true;
				break;
				case 15:
					coluna6.TransfereCarta(&coluna7);
					return true;
				break;
				case 16:
					coluna6.TransfereCarta(&coluna8);
					return true;
				break;
			}
		break;
		case 15:
			switch(destino)
			{
				case 1:
					coluna7.ParaReserva(&reserva1);
					return true;
				break;
				case 2:
					coluna7.ParaReserva(&reserva2);
					return true;
				break;
				case 3:
					coluna7.ParaReserva(&reserva3);
					return true;
				break;
				case 4:
					coluna7.ParaReserva(&reserva4);
					return true;
				break;
				case 5:
					coluna7.SobeCarta(&cima1);
					return true;
				break;
				case 6:
					coluna7.SobeCarta(&cima2);
					return true;
				break;
				case 7:
					coluna7.SobeCarta(&cima3);
					return true;
				break;
				case 8:
					coluna7.SobeCarta(&cima4);
					return true;
				break;
				case 10:
					coluna7.TransfereCarta(&coluna2);
					return true;
				break;
				case 11:
					coluna7.TransfereCarta(&coluna3);
					return true;
				break;
				case 12:
					coluna7.TransfereCarta(&coluna4);
					return true;
				break;
				case 13:
					coluna7.TransfereCarta(&coluna5);
					return true;
				break;
				case 14:
					coluna7.TransfereCarta(&coluna6);
					return true;
				break;
				case 9:
					coluna7.TransfereCarta(&coluna1);
					return true;
				break;
				case 16:
					coluna7.TransfereCarta(&coluna8);
					return true;
				break;
			}
		break;
		case 16:
			switch(destino)
			{
				case 1:
					coluna8.ParaReserva(&reserva1);
					return true;
				break;
				case 2:
					coluna8.ParaReserva(&reserva2);
					return true;
				break;
				case 3:
					coluna8.ParaReserva(&reserva3);
					return true;
				break;
				case 4:
					coluna8.ParaReserva(&reserva4);
					return true;
				break;
				case 5:
					coluna8.SobeCarta(&cima1);
					return true;
				break;
				case 6:
					coluna8.SobeCarta(&cima2);
					return true;
				break;
				case 7:
					coluna8.SobeCarta(&cima3);
					return true;
				break;
				case 8:
					coluna8.SobeCarta(&cima4);
					return true;
				break;
				case 10:
					coluna8.TransfereCarta(&coluna2);
					return true;
				break;
				case 11:
					coluna8.TransfereCarta(&coluna3);
					return true;
				break;
				case 12:
					coluna8.TransfereCarta(&coluna4);
					return true;
				break;
				case 13:
					coluna8.TransfereCarta(&coluna5);
					return true;
				break;
				case 14:
					coluna8.TransfereCarta(&coluna6);
					return true;
				break;
				case 15:
					coluna8.TransfereCarta(&coluna7);
					return true;
				break;
				case 9:
					coluna8.TransfereCarta(&coluna1);
					return true;
				break;
			}
		break;
	}
	
	return false;
}
			

			

